var areacode = localStorage.getItem("areaCode"),
    areaname = localStorage.getItem("areaName");
$(".city").text("当前选择城市: "+areaname);
function getPro1(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=1",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              var tab1content = document.querySelector("#tab1"),
                  tab1contentHtml = "<div class=\"gsxw1\"><span>农气评价</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/jieqi.jpg\" title=\"农气评价\" width=\"305\" height=\"100\"/>" +
                                "</div>";
                  tab1content.innerHTML = tab1contentHtml;
                  tab1contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab1contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].createDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab1contentHtml += "</ul>" +
                                     "</div>";
                  tab1content.innerHTML = tab1contentHtml;                                
        }
    });
}
getPro1(areacode);

function getPro2(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=2",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              var tab2content = document.querySelector("#tab2"),
                  tab2contentHtml = "<div class=\"gsxw1\"><span>农气预报</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/yubao.jpg\" title=\"农气预报\" width=\"305\" height=\"100\"/>" +
                                "</div>";
                  tab2content.innerHTML = tab2contentHtml;
                  tab2contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab2contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].createDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab2contentHtml += "</ul>" +
                                     "</div>";
                  tab2content.innerHTML = tab2contentHtml;                                
        }
    });
}
getPro2(areacode);

function getPro3(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=3",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              
              var tab3content = document.querySelector("#tab3"),
                  tab3contentHtml = "<div class=\"gsxw1\"><span>监测与预警</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/zhjcyj.jpg\" title=\"监测与预警\" width=\"305\" height=\"100\"/>" +
                                "</div>";
                  tab3content.innerHTML = tab3contentHtml;
                  tab3contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab3contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].updateDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab3contentHtml += "</ul>" +
                                     "</div>";
                  tab3content.innerHTML = tab3contentHtml;                                
        }
    });
}
getPro3(areacode);

function getPro4(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=4",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              var tab4content = document.querySelector("#tab4"),
                  tab4contentHtml = "<div class=\"gsxw1\"><span>节气与农业</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/pingjia.png\" title=\"节气与农业\" width=\"305\" height=\"100\" />" +
                                "</div>";
                  tab4content.innerHTML = tab4contentHtml;
                  tab4contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab4contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].createDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab4contentHtml += "</ul>" +
                                     "</div>";
                  tab4content.innerHTML = tab4contentHtml;                                
        }
    });
}
getPro4(areacode);

function getPro5(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=5",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              var tab5content = document.querySelector("#tab5"),
                  tab5contentHtml = "<div class=\"gsxw1\"><span>农业实况</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/shikuang.png\" title=\"农业实况\" width=\"305\" height=\"100\" />" +
                                "</div>";
                  tab5content.innerHTML = tab5contentHtml;
                  tab5contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab5contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].createDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab5contentHtml += "</ul>" +
                                     "</div>";
                  tab5content.innerHTML = tab5contentHtml;                                
        }
    });
}
getPro5(areacode);

function getPro6(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getProductsByContentTypeAndAreaCodeAndBrand&area="+ areaCode +"&brand=&type=6",
        type: "GET",
        dataType: "json", 
        success: function(childata) {
              console.log(childata);
              var tab6content = document.querySelector("#tab6"),
                  tab6contentHtml = "<div class=\"gsxw1\"><span>其他</span></div>" +
                                "<div class=\"diyi\"><img src=\"templets/lbagri/statics/images/product/kepuzx.jpg\" title=\"其他\" width=\"305\" height=\"100\" />" +
                                "</div>";
                  tab6content.innerHTML = tab6contentHtml;
                  tab6contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                     "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">";
                                     for(i=0;i<childata.length;i++){
                                       tab6contentHtml += "<li><a style=\"overflow: hidden;text-overflow: ellipsis;white-space: nowrap; width: 208px;\" href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[i].folderName + "/" + childata[i].id +".html\" target=\"_blank\" title=\""+ childata[i].productName +"\">"+ childata[i].productName +"</a><span>"+ dateProcess(childata[i].createDate) +"</span></li>";
                                       if(i==5) break;
                                     } 
                  tab6contentHtml += "</ul>" +
                                     "</div>";
                  tab6content.innerHTML = tab6contentHtml;                                
        }
    });
}
getPro6(areacode);

function dateProcess(date){ //产品时间戳处理
    var time = new Date(date),
        timeyear = time.getFullYear(),
        timemonth = time.getMonth()+1,
        timeday = time.getDate();
        if( timemonth < 10 ){
            timemonth = "0" + timemonth;
        }
        if( timeday < 10 ){
            timeday = "0" + timeday;
        }
        timeyear = ""+timeyear;
        timeyear = timeyear.substring(2);
        return timeyear+"-"+timemonth+"-"+timeday;
}